package com.codebattery.repository;

import com.codebattery.domain.model.DeviceInfo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import com.codebattery.domain.entity.Device;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface DeviceRepository extends JpaRepository<Device, Integer>, JpaSpecificationExecutor<Device> {

        @Query(value="SELECT new com.codebattery.domain.model.DeviceInfo("
            +"id, type, name, address, serialNum, remark"
            + ") FROM "
            + " com.codebattery.domain.entity.Device d ")
        Page<DeviceInfo> queryDevices(Pageable pageable);

}